package JAVASE522;

public class String1 {
    public static void main(String[] argc){
        int[] arr={1,2,3};
        System.out.println(intTostring(arr));
    }

    //{1,2,3}to[1,2,3]
    public static String intTostring(int[] arr) {
        if (arr == null) {
            return "";
        }
        if (arr.length == 0) {
            return "[]";
        }
        String result = "[";
        for (int i = 0; i < arr.length; i++) {
            if (i != arr.length - 1) {
                result = result  + arr[i] + ",";
            }else{
                result = result +  arr[i] + "]";
            }
        }
        return result;
    }
}